﻿using System;

namespace ConsoleApplication16
{
    class FactorialProgram
    {
        public static void Main2()
        {
            Console.WriteLine(faclist().Skip(5)().Item1);
        }

        static Chain<int> faclist()
        {
            return new {n = 0, fac = 1}.Chain(seed => {
                var n = seed.n + 1;
                return Tuple.Create(seed.fac, new {n, fac = seed.fac*n});
            });
        }
    }
}